home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12316 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: A solution and another pointer question
  5. Date: Sun, 31 Mar 96 12:36:08 GMT
  6. Organization: none
  7. Distribution: world
  8. Message-ID: <828275768snz@genesis.demon.co.uk>
  9. References: <4jhhak$131a@sol.caps.maine.edu>
  10. Reply-To: fred@genesis.demon.co.uk
  11. X-NNTP-Posting-Host: genesis.demon.co.uk
  12. X-Newsreader: Demon Internet Simple News v1.27
  13. X-Mail2News-Path: genesis.demon.co.uk
  14.  
  15. In article <4jhhak$131a@sol.caps.maine.edu>
  16.            bensh@gandalf.UMCS.Maine.EDU "Shawn Benn" writes:
  17.  
  18. >FILE* fil;
  19. >char* filename = "junk";      /* junk used just as an example */
  20. >
  21. >fil = fopen(filename, "rb");
  22. >fseek(fil, 0L, SEEK_END);
  23. >
  24. >I get a Segmentation Fault error here trying to get to the end of the file.
  25. >
  26. >Any ideas?  Thanks again for any help.  
  27.  
  28. Check the return code of fopen() for failure. Trying to pass a null pointer
  29. to fseek() results in undefined behaviour. Other than that the code is
  30. fine (or at least as much as we can see of it).
  31.  
  32. -- 
  33. -----------------------------------------
  34. Lawrence Kirby | fred@genesis.demon.co.uk
  35. Wilts, England | 70734.126@compuserve.com
  36. -----------------------------------------
  37.